<?php
/*
+--------------------------------------------------------------------------
|   phpBIZbiz v3.0 full version
|   ========================================
|   by taft@wjl.cn
|   http://www.phpbiz.cn
|   all rights reserved
+---------------------------------------------------------------------------
|
|   > 
|   > 最后修改日期：2005-9-9
|   > 
|
+--------------------------------------------------------------------------
*/
!function_exists('do_login') && exit('Forbidden');
$index = new ad_index;
class ad_index
{
	var $base_url;
	
   /**
	*     ad_index构造函数
	*
	*     @access public
	*/

	function ad_index()
	{
		global $CONF,$ADMIN,$SKIN,$DB;

		$this -> base_url = $CONF['admin_url']."admin.".$CONF['php_ext'];

		//---------------------------------------
		// Kill globals - globals bad, Homer good.
		//---------------------------------------
		
		$tmp_in = array_merge( $_GET, $_POST, $_COOKIE );
		
		foreach ( $tmp_in as $k => $v )
		{
			unset($$k);
		}
		
		//---------------------------------------

        $ADMIN -> page_title = "欢迎来到phpBIZ版管理面板";
        $ADMIN->page_instruction = "你在这个控制面板中能够设定phpBIZ相关选项。<br><br>点击左面的菜单条中的一个链接将显示这个管理类别的相关的选项。每一个选项都包含一个配置的特性信息，等等。";

		$ADMIN -> nav[] = array("","管理首页");


	    /*-------- counting... --------*/
		
		$SKIN->td_header[] = array( "定义", "25%" );
		$SKIN->td_header[] = array( "值"  , "25%" );
		$SKIN->td_header[] = array( "定义", "25%" );
		$SKIN->td_header[] = array( "值"  , "25%" );

		$ADMIN -> html .= $SKIN -> table_head( "系统总览:" );
        $ct1 = $this -> counting( "biz_seller" ); $ct2 = $this -> counting( "biz_shop" );
		$ADMIN -> html .= $SKIN -> table_row( array( "商家总计:","{$ct1}","店铺总计","{$ct2}" ) );
        $ct1 = $this -> counting( "biz_seller","seller_check_status ='uncheck'" );$ct2 = $this -> counting( "biz_shop", "shop_check_status ='uncheck'" );
		$ADMIN -> html .= $SKIN -> table_row( array( "<a href='{$this -> base_url}?act=mem&code=check'>待验证的商家</a>","{$ct1}", "<a href='{$this -> base_url}?act=shop&code=check'>待验证的店铺</a>","{$ct2}")  );
        $ct = $this -> counting( "biz_goods" );
		$ct_user = $this ->counting("biz_session");
		
		$DB -> db_query("SELECT  running_time as rt FROM biz_session ORDER BY running_time ASC");
		$res = $DB -> db_fetch_row();
		$tm = date("m-d H:i",$res['rt']);
		$ADMIN -> html .= $SKIN -> table_row( array( "商品总计","{$ct}","活动用户(至{$tm})","{$ct_user}"));
		$ct = $this -> counting( "biz_goods","goods_mark_sell='1'" );
		$ADMIN -> html .= $SKIN -> table_row( array( "停售商品","{$ct}","",""));


		$ADMIN -> html .= $SKIN -> table_end();

		$ADMIN -> html .= $SKIN -> td_spacer();	
		
		/*------ LAST 5 Admin Actions LOG --------*/
		
		$SKIN->td_header[] = array( "用户名"            , "20%" );
		$SKIN->td_header[] = array( "执行操作"        , "40%" );
		$SKIN->td_header[] = array( "操作时间"         , "20%" );
		$SKIN->td_header[] = array( "IP地址"             , "20%" );
	    $ADMIN ->html .= $SKIN -> table_head( "最后5个管理操作" );

        $DB -> db_query( "select m.user_account, l.*  from biz_admin_log l, biz_admin_user m WHERE m.user_id = l.user_id  ORDER BY l.log_time DESC LIMIT 0, 5 " );
        if( $DB -> db_fetch_num() )
		{
			while( $record = $DB -> db_fetch_row() )
			{
				$ADMIN -> html .= $SKIN -> table_row(
					                  array("<b>{$record[user_account]}</b>", 
					                        "{$record[log_content]}",
					                        "{$record[log_time]}",
					                        "{$record[log_ip]}")
					                        );
			}
		
		}else{
		
		$ADMIN -> html .= $SKIN -> td_basic( "<center>日志信息丢失！</center>" );
		
		}
         
        $ADMIN -> html .= $SKIN -> table_end();

		$ADMIN -> html .= $SKIN -> td_spacer();
		

		/*----------- fast edit ---------------*/

		

		$SKIN->td_header[] = array( "&nbsp;"  , "40%" );
		$SKIN->td_header[] = array( "&nbsp;"  , "30%" );
		$SKIN->td_header[] = array( "&nbsp;"  , "30%" );

		$ADMIN -> html .= $SKIN -> table_head( "快速编辑" );$ADMIN -> html .= $SKIN -> form_head();
		$ADMIN -> html .= "
									<script language='javascript'>
				                	<!--
									 function edit_member() 
								     {
										if (document.forms[0].username.value == \"\") 
										{
						                     alert(\"你必须键入一个商家名！\");
						                } else {
							                 window.parent.body.location = '{$this->base_url}' + '?act=mem&code=findseller&SELLER_NAME=' + escape(document.forms[0].username.value);
						                }
					                  }
									 function edit_shop() 
								     {
										if (document.forms[0].shop_name.value == \"\") 
										{
						                     alert(\"你必须键入一个商铺名！\");
						                } else {
							                 window.parent.body.location = '{$this->base_url}' + '?act=mem&code=findshop&SHOP_NAME=' + escape(document.forms[0].shop_name.value);
						                }
					                  }
									  //-->
					
					                </script>
							";
		$ADMIN->html .= $SKIN->table_row( array( "编辑商家：",
												  "<input type='text' style='width:100%' id='textinput' name='username' value='在这里键入商家名' onfocus='this.value=\"\"'>",
												  "<input type='button' value='查找商家' id='button' onClick='edit_member()'>"
										 )      );
		
		$ADMIN->html .= $SKIN->table_row( array( "编辑商铺：",
												  "<input type='text' style='width:100%' name='shop_name' id='textinput' value='在这里键入商铺名' onfocus='this.value=\"\"'>",
												  "<input type='button' value='查找商铺' id='button' onClick='edit_shop()'>"
										 )      );

					  
		$ADMIN -> html .= $SKIN -> form_end();	
		$ADMIN->html .= $SKIN->table_end();
		
		$ADMIN -> html .= $SKIN -> td_spacer();
		/*----------------develop group info----------*/
		$SKIN -> td_header[] = array("","");
		$ADMIN -> html .= $SKIN -> table_head("开发团队");
		$ADMIN -> html .= $SKIN -> table_row(array("program: taft yejun iamPaulYoung"));
		$ADMIN -> html .= $SKIN -> td_basic("特别感谢", 'left', 'catrow2');
		$ADMIN -> html .= $SKIN -> table_row(array("~墨鱼串烧~ carter003"));
		$ADMIN -> html .= $SKIN -> table_end();

		$ADMIN->output();
		


	}

   /**
	*     
	*     分类统计    
	* 
	*     @param  string  类别
	*
	*     @access private
	*/

	function counting( $table , $condition ="" )
	{
        global $DB;

		$sql = "select count(*) as num from $table where 1 ";

		if( $condition ) $sql .= "and ".$condition;
		
		$DB -> db_query( $sql );
		$res = $DB -> db_fetch_row();

		return $res['num'];
	}



}



?>